import time


def fibonacci(n, k=1):
    if n <= 2:
        return 1
    else:
        return fibonacci(n-1, k) + fibonacci(n-2, k) * k


def fibonacci2(n, k):
    b, a = 1, 0
    for i in range(2, n + 1):
        b, a = b + a * k, b
    return b

n = 10
k = 1
n_times = 1000

st = time.perf_counter()
for i in range(n_times):
    fibonacci(n, k)
et = time.perf_counter()

time1 = et - st
print(f"Time for recursive: {(et - st)}s")

st = time.perf_counter()
for i in range(n_times):
    fibonacci2(n, k)
et = time.perf_counter()

time2 = et - st
print(f"Time for loops: {(et - st)}s")

print(f"The ratio of loops to recursive: {time1 / time2}s")
